package com.cn.enumeration.gpt;

public class Demo2 {
    public static void main(String[] args) {
        Color2 red = Color2.RED;
        System.out.println("My color is " + red + "with hex code" +red.getHexCode());
    }
}

enum Color2{
    RED("#FF0000"),GREEN("#00FF00"), BLUE("#0000FF");
    private String hexCode;

    //构造方法
    Color2(String hexCode){
        this.hexCode = hexCode;
    }
    //获取颜色代码的方法
    public String getHexCode(){
        return hexCode;
    }
}